//
//  AppIntroduceVC.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/7/6.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "AppIntroduceVC.h"
#import "MainTabBarVC.h"

@interface AppIntroduceVC ()<UIScrollViewDelegate>


@property (weak, nonatomic) IBOutlet UIImageView *imageView1;
@property (weak, nonatomic) IBOutlet UIImageView *imageView2;
@property (weak, nonatomic) IBOutlet UIImageView *imageView3;
@property (weak, nonatomic) IBOutlet UIButton *funBtn;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageImageViewW;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageImageViewH;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textImageViewW;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textImageViewH;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageViewCenterY;


@end

@implementation AppIntroduceVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIImage *image1 = [UIImage imageNamed:MYLocalizedString(@"GUIDE_PNG1", nil)];
    UIImage *image2 = [UIImage imageNamed:@"guide1"];
    
    self.imageView1.image = image1;
    self.imageView2.image = [UIImage imageNamed:MYLocalizedString(@"GUIDE_PNG2", nil)];
    self.imageView3.image = [UIImage imageNamed:MYLocalizedString(@"GUIDE_PNG3", nil)];
    
    self.funBtn.layer.borderColor = kContentColor.CGColor;
    self.funBtn.layer.borderWidth = 1.0f;
    [self.funBtn setTitleColor:kContentColor forState:UIControlStateNormal];
    [self.funBtn setTitle:MYLocalizedString(@"LAUNCH_GOTO_MAIN_BTN", nil) forState:UIControlStateNormal];
    
    
    CGFloat imageW = image2.size.width;
    CGFloat imageH = image2.size.height;
    
    CGFloat textW = image1.size.width;
    CGFloat textH = image1.size.height;
    
    CGFloat ratio = 1;
    
    if (ISiPhone4) {
        
        ratio = 0.7;
    } else if (ISiPhone5) {
        ratio = 0.9;
    } else if (ISiPhone6p) {
        
        ratio = 1.1;
    } else if (ISiPhoneX) {
        
        ratio = 1.1;
    }
    
    self.imageImageViewW.constant = imageW *ratio;
    self.imageImageViewH.constant = imageH *ratio;
    self.textImageViewW.constant = textW *ratio;
    self.textImageViewH.constant = textH *ratio;
    
    self.imageViewCenterY.constant = - textH * ratio / 2.0f - 20;
}

- (IBAction)funAction:(id)sender {
    
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasInApp"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    
    MainTabBarVC *tabVC = [MainTabBarVC new];
    
    [UIApplication sharedApplication].keyWindow.rootViewController = tabVC;
}

@end

